package com.glenet.salary.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;

import com.glenet.salary.entities.HrPreSalaryDetail;
import com.glenet.salary.util.SessionFactoryUtil;
 
public class HrPreSalaryDetailDao extends HrDaoSuport {
	
	@SuppressWarnings("unchecked")
	public List<HrPreSalaryDetail> list(int offset, int limit){
		List<HrPreSalaryDetail> list = new ArrayList<HrPreSalaryDetail>();
		try {
			SqlSession session = SessionFactoryUtil.getSessionFactory().openSession();
			list =	session.selectList("HrPreSalaryDetail.select", null , new RowBounds(offset, limit));
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	
	public int batchImport(List<HrPreSalaryDetail> list) {
		int effect = 0;
		try {
			SqlSession session = SessionFactoryUtil.getSessionFactory().openSession(ExecutorType.BATCH);
			for (HrPreSalaryDetail out : list) {
				session.insert("HrPreSalaryDetail.insert", out);
			}
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return effect;
	}
}
